home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10377 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: vivid.autometric.com!usenet
  2. From: Joe Shelby <jshelby@autometric.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: enumerated types and the new c++ standard...
  5. Date: Thu, 07 Mar 1996 11:28:48 -0500
  6. Organization: Vision International, a division of Autometric, Inc.
  7. Message-ID: <313F0EC0.2781@autometric.com>
  8. NNTP-Posting-Host: vivid.autometric.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; IRIX 5.3 IP22)
  13.  
  14. enumerated types and the new c++ standard...
  15.  
  16. it seems as though the C++ standards body has created something
  17. of a contradiction...
  18.  
  19. they (for some odd reason) declared that enumerated types
  20. are no longer "integral", meaning for something like
  21.  
  22. enum Wday { SUN = 0, MON, TUE, WED, THU, FRI, SAT } wday;
  23.  
  24. the line:
  25.  
  26. for (wday = SUN; w <= SAT; w++) {;}
  27.  
  28. is no longer legal C++ (even though it is legal C). (and gcc 2.7.2
  29. respects this change and won't allow the code);  the key problem
  30. is that <= and ++ are no longer defined for enumerated types...
  31.  
  32. yet at the same time, i've not read anything that states that
  33. enum's can't be used as array indexes (meaning they inheritantly
  34. MUST be integral); and i've used them as array indexes
  35. with no warnings or problems whatsoever.
  36.  
  37. why did the standards body choose the change?  it seems that we
  38. now have to go back to the dreaded "#define" approach in order
  39. to get the desired code style...  OR i can go about implementing
  40. a <= and a ++ operator, which can get VERY inefficient with
  41. "switch/case" statements and all that...
  42.  
  43. joe
  44.  
  45. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  46. Joseph Shelby : Software Engineer                      jshelby@autometric.com
  47. 5301 Shawnee Rd. Alexandria, VA  22312-2333                    (703) 658-4071
  48.                         http://www.io.com/~acroyear
  49. I'm not sure who he is, but I've heard he's got his hand in a lot of things.
  50.                                         --Kermit, about Jim Henson
  51. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  52.